﻿using Lis.Dto;
using Lis.IBLL;
using Lis.Model;
using Lis.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lis.BLL
{
    public class CirculateService : BaseService<LoanBookDto>, ICirculateService
    {
        #region 01，根据读者卡号获取当前借阅信息+ServiceResult<IEnumerable<object>> GetEntitiesOfLoanByUserName(string userName)
        /// <summary>
        /// 根据读者卡号获取当前借阅信息
        /// </summary>
        /// <param name="userName">读者卡号</param>
        /// <returns></returns>
        public ServiceResult<IEnumerable<object>> GetEntitiesOfLoanByUserName(string userName)
        {
            if (!string.IsNullOrEmpty(userName))
            {
                return new ServiceResult<IEnumerable<object>>()
                {
                    Success = true,
                    Result = ((CirculateRepository)DBSession.SysCirculateRepository).GetEntitiesOfLoanByUserName(userName),
                    Message = "",
                    Code = "10000"
                };
            }
            else
            {
                return new ServiceResult<IEnumerable<object>>()
                {
                    Success = false,
                    Result = null,
                    Message = "请输入正确的卡号进行查询",
                    Code = "10001"
                };
            }
        } 
        #endregion
        #region 01，根据读者卡号获取借阅历史+ServiceResult<IEnumerable<object>> GetEntitiesOfLoanHistoryByUserName(string userName)
        /// <summary>
        /// 根据读者卡号获取借阅历史
        /// </summary>
        /// <param name="userName">读者卡号</param>
        /// <returns></returns>
        public ServiceResult<IEnumerable<object>> GetEntitiesOfLoanHistoryByUserName(string userName)
        {
            if (!string.IsNullOrEmpty(userName))
            {
                return new ServiceResult<IEnumerable<object>>()
                {
                    Success = true,
                    Result = ((CirculateRepository)DBSession.SysCirculateRepository).GetEntitiesOfLoanHistoryByUserName(userName),
                    Message = "",
                    Code = "10000"
                };
            }
            else
            {
                return new ServiceResult<IEnumerable<object>>()
                {
                    Success = false,
                    Result = null,
                    Message = "请输入正确的卡号进行查询",
                    Code = "10001"
                };
            }
        } 
        #endregion

        public override IQueryable<LoanBookDto> GetPageEntities<S>(int pageSize, int pageIndex, out int total, bool isAsc, System.Linq.Expressions.Expression<Func<LoanBookDto, bool>> whereLambda, System.Linq.Expressions.Expression<Func<LoanBookDto, S>> orderByLambda)
        {
            throw new NotImplementedException();
        }

        public override bool Add(LoanBookDto entity)
        {
            throw new NotImplementedException();
        }

        public override bool UpDate(LoanBookDto entity)
        {
            throw new NotImplementedException();
        }

        public override bool Delete(LoanBookDto entity)
        {
            throw new NotImplementedException();
        }
    }
}
